import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 中高技班级课信息 */
export interface VocationalClassSchedule {
          id: number; // 中高技班级课表id
          term?: string; // 学期信息，如 2024-2025学年 第二学期
          className?: string; // 班级名称，如 25年春体验班
          classSection?: string; // 节次，如 早1 08:00-08:20
          mondayCourse: string; // 周一的课程信息，包括课程名、教师、教室等
          tuesdayCourse: string; // 周二的课程信息，包括课程名、教师、教室等
          wednesdayCourse: string; // 周三的课程信息，包括课程名、教师、教室等
          thursdayCourse: string; // 周四的课程信息，包括课程名、教师、教室等
          fridayCourse: string; // 周五的课程信息，包括课程名、教师、教室等
          classTeacher: string; // 班主任姓名，如 彭平
          classroom: string; // 教室信息，如 B215
  }

// 中高技班级课 API
export const VocationalClassScheduleApi = {
  // 查询中高技班级课分页
  getVocationalClassSchedulePage: async (params: any) => {
    return await request.get({ url: `/ao/vocational-class-schedule/page`, params })
  },

  // 查询中高技班级课详情
  getVocationalClassSchedule: async (id: number) => {
    return await request.get({ url: `/ao/vocational-class-schedule/get?id=` + id })
  },

  // 新增中高技班级课
  createVocationalClassSchedule: async (data: VocationalClassSchedule) => {
    return await request.post({ url: `/ao/vocational-class-schedule/create`, data })
  },

  // 修改中高技班级课
  updateVocationalClassSchedule: async (data: VocationalClassSchedule) => {
    return await request.put({ url: `/ao/vocational-class-schedule/update`, data })
  },

  // 删除中高技班级课
  deleteVocationalClassSchedule: async (id: number) => {
    return await request.delete({ url: `/ao/vocational-class-schedule/delete?id=` + id })
  },

  /** 批量删除中高技班级课 */
  deleteVocationalClassScheduleList: async (ids: number[]) => {
    return await request.delete({ url: `/ao/vocational-class-schedule/delete-list?ids=${ids.join(',')}` })
  },

  // 导出中高技班级课 Excel
  exportVocationalClassSchedule: async (params) => {
    return await request.download({ url: `/ao/vocational-class-schedule/export-excel`, params })
  },

  // 获得导入中高技班级课模板
  importVocationalClassScheduleTemplate: async () => {
    return await request.download({ url: `/ao/vocational-class-schedule/get-import-template` })
  },

  // 获取Excel文件中的工作表名称
  getSheetNames: async (file: File) => {
    const formData = new FormData()
    formData.append('file', file)
    return await request.upload({ url: `/ao/vocational-class-schedule/get-sheet-names`, data: formData })
  },

  // 导入中高技班级课
  importVocationalClassSchedule: async (file: File, updateSupport: boolean, sheetName?: string) => {
    const formData = new FormData()
    formData.append('file', file)
    formData.append('updateSupport', String(updateSupport))
    if (sheetName) {
      formData.append('sheetName', sheetName)
    }
    return await request.upload({ url: `/ao/vocational-class-schedule/import`, data: formData })
  },
}
